package net.tensor.tensorprovider.controller;

import ch.qos.logback.classic.LoggerContext;
import lombok.extern.slf4j.Slf4j;
import net.tensor.tensorprovider.database.entity.TmpActUser;
import net.tensor.tensorprovider.database.entity.TmpProcInst;
import net.tensor.tensorprovider.database.service.impl.TmpActUserServiceImpl;
import net.tensor.tensorprovider.database.service.impl.TmpProcInstServiceImpl;
import net.tensor.tensorprovider.database.service.impl.TmpUser1m2ServiceImpl;
import net.tensor.tensorprovider.exception.GlobalExceptionHandler;
import net.tensor.tensorprovider.exception.ResultBody;
import net.tensor.tensorprovider.service.impl.HelloServiceImpl;
import net.tensor.tensorprovider.zhujie.anonation.Token;
import org.slf4j.ILoggerFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author Q
 */
@Slf4j
@RestController
@RequestMapping
public class HelloController {
    @Autowired
    private HelloServiceImpl helloService;
    @Autowired
    private TmpProcInstServiceImpl tmpProcInstService;
    @Autowired
    private TmpActUserServiceImpl tmpActUserService;
    @Autowired
    private TmpUser1m2ServiceImpl tmpUser1m2Service;

    private static final Logger logger = LoggerFactory.getLogger(HelloController.class);

    @GetMapping("/name")
    public String getName() {
        return helloService.getName();
    }

    @GetMapping("/procInst")
    public List<TmpProcInst> test() {
        return tmpProcInstService.list();
    }

    @GetMapping("/user")
    public List<TmpActUser> userList() {
        return tmpActUserService.list();
    }

    @GetMapping("/user2")
    public ResultBody tmpUser1m2s() {
        ResultBody resultBody = new ResultBody();
        resultBody.setCode("200");
        resultBody.setMessage("成功");
        resultBody.setResult(tmpUser1m2Service.list());
        return resultBody;
    }

    @GetMapping("/anonation/{token}")
    @Token
    public String test(@PathVariable(name = "token") String token){
        return token;
    }
}
